package com.battery.controller;


import com.battery.pojo.Vip_Type;
import com.battery.service.Vip_TypeService;
import com.battery.util.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "会员类型管理相关接口")
public class Vip_TypeController {
    @Autowired
    Vip_TypeService vip_typeService;

    @PostMapping("/Vip_type")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("列出所有会员类型")
    public Result showVip_type(){
        return Result.ok().data("data",vip_typeService.findAllVip_Type());
    }


    @PostMapping("/addVip_type")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("添加会员类型")
    public Result addVip_type(Vip_Type vip_type){
        return Result.ok().data("data",vip_typeService.addVip_Type(vip_type));
    }


    @DeleteMapping("/deleteVip_type/{vip_type_id}")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("删除会员类型")
    public Result deleteVip_type(@PathVariable("vip_type_id") int vip_type_id){

        return Result.ok().data("data",vip_typeService.removeVip_Type(vip_type_id));

    }

    @GetMapping("/searchVip_type/{vip_type_id}")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("查找会员类型")
    public Result searchVip_type(@PathVariable("vip_type_id") int vip_type_id){

        return Result.ok().data("data",vip_typeService.searchVip_Type(vip_type_id));

    }

    @PutMapping("/changeVip_type")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("修改会员类型")
    public Result changeVip_type(Vip_Type vip_type){

        return Result.ok().data("data",vip_typeService.changeVip_Type(vip_type));

    }




}
